﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="User_Register" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>注册 </title>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="js/jquery.processing.plugin.js" type="text/javascript"></script>
    <link href="css/zhuce.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="main">
        <div class="cpzx_zc_main" id="register">
            <div class="cpzx_zc_main1l">
            </div>
            <div class="cpzx_zc_main1m">
                <div class="cpzx_zc_zc">
                    <strong style="margin-left: 30px;">昵称注册</strong><span style="font-size: 12px;">（带<span
                        class="color_red2">*</span>号为必填项）</span></div>
                <div class="cpzx_zc_zcall">
                    <div class="cpzx_zc_dlsj fl">
                        <div class="cpzx_zc_sjz1">
                            <span class="color_red2">*</span>昵称</div>
                        <div class="cpzx_zc_dlsr">
                            <input name="dlsr" type="text" id="txt_RegName" maxlength="16" style="margin-left: 8px;
                                line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                    </div>
                    <div class="h23" style="display: none;" id="regNameMsg">
                        <div class="cpzx_zc_x">
                        </div>
                        <div class="cpzx_zc_x1">
                            该昵称已注册</div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="cpzx_zc_jiange1">
                        <div class="cpzx_zc_gantan">
                        </div>
                        <div class="cpzx_zc_gantanz">
                            请输入以字母开头的2-16个字符</div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="w318">
                        <div class="cpzx_zc_dlsj">
                            <div class="cpzx_zc_sjz1">
                                <span class="color_red2">*</span>登录密码</div>
                            <div class="cpzx_zc_dlsr">
                                <input name="dlsr" type="password" id="txt_RegPW" maxlength="15" style="margin-left: 8px;
                                    line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" />
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="cpzx_zc_jiange2">
                            <div class="cpzx_zc_gantan">
                            </div>
                            <div class="cpzx_zc_gantanz1">
                                密码请输入6-15个字符</div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="cpzx_zc_dlsj">
                            <div class="cpzx_zc_sjz1">
                                <span class="color_red2">*</span>再次输入登录密码</div>
                            <div class="cpzx_zc_dlsr">
                                <input name="dlsr" type="password" id="txt_RegPWD" maxlength="15" style="margin-left: 8px;
                                    line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="cpzx_zc_jiange2">
                            <div class="clear">
                            </div>
                        </div>
                        <div class="cpzx_zc_dlsj">
                            <div class="cpzx_zc_sjz1">
                                手机号</div>
                            <div class="cpzx_zc_dlsr">
                                <input name="dlsr" type="text" id="txt_RegMobile" maxlength="11" style="margin-left: 8px;
                                    line-height: 22px; width: 168px; height: 20px; float: left; margin-top: 1px;" /></div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="cpzx_zc_jiange2">
                            <div class="cpzx_zc_gantan">
                            </div>
                            <div class="cpzx_zc_gantanz1">
                                输入手机号码立即体验正式版</div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="h23">
                        <div class="cpzx_zc_x2">
                            <div id="regPwMsg" style="display: none;">
                                <div class="cpzx_zc_x">
                                </div>
                                <div class="cpzx_zc_x1">
                                    密码不能小于6位</div>
                            </div>
                            <div class="cpzx_zc_y" style="display: none;">
                            </div>
                        </div>
                        <div class="cpzx_zc_x2">
                            <div id="regPwdMsg" style="display: none;">
                                <div class="cpzx_zc_x">
                                </div>
                                <div class="cpzx_zc_x1">
                                    两次密码输入不<br />
                                    一致</div>
                            </div>
                            <div class="cpzx_zc_y" style="display: none;">
                            </div>
                        </div>
                        <div class="cpzx_zc_x2">
                            <div id="regMobileMsg" style="display: none;">
                                <div class="cpzx_zc_x">
                                </div>
                                <div class="cpzx_zc_x1">
                                    请输入有效手机<br />
                                    号码</div>
                            </div>
                            <div class="cpzx_zc_y" style="display: none;">
                            </div>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="cpzx_zc_dlsj1">
                        <div class="cpzx_zc_sjz1">
                            手机号码验证</div>
                        <div class="cpzx_zc_dlsr1">
                            <input name="dlsr1" type="text" class="cpzx_zc_dlsr1" id="txt_MobileCode" style="padding-left: 8px;
                                line-height: 24px;" /></div>
                        <div class="pl8 fl">
                            <input type="button" onclick="return GetMobileVerify();" id="btn_GetCode" style="cursor: pointer;
                                width: 73px; height: 24px; background: url(image/GetPwd.PNG) 0px 0px no-repeat;" />
                        </div>
                        <div id="regMobileCodeMsg" style="display: none;">
                            <div class="cpzx_zc_x">
                            </div>
                            <div class="cpzx_zc_x1">
                                手机验证码错误</div>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="cpzx_zc_jiange1">
                        <div class="cpzx_zc_gantan">
                        </div>
                        <div class="cpzx_zc_gantanz">
                            <span class="color_yellow">如未收到验证码，请再次点击&quot;获取验证码&quot;</span></div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="cpzx_zc_dlsj1">
                        <div class="cpzx_zc_sjz1">
                            <span class="color_red2">*</span>验证码</div>
                        <div class="cpzx_zc_dlsr1">
                            <input name="dlsr1" type="text" id="txt_RegCheckCode" maxlength="4" class="cpzx_zc_dlsr1"
                                style="padding-left: 8px; line-height: 24px;" /></div>
                        <div class="pl8 fl">
                            <img alt="" width="54" height="23" id="regimgcode" src="../ePioneer/RegImg.aspx"
                                onclick="GetCode();" style="cursor: pointer;" />
                        </div>
                        <div id="regCheckCodeMsg" style="display: none;">
                            <div class="cpzx_zc_x pl8">
                            </div>
                            <div class="cpzx_zc_x1">
                                验证码输入错误</div>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="cpzx_zc_jiange1">
                        <div class="cpzx_zc_gantan">
                        </div>
                        <div class="cpzx_zc_gantanz1">
                            <div onclick="GetCode();" style="color: #602012; text-decoration: underline; cursor: pointer;">
                                看不清，点击验证码换一张</div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="cpzx_zczcbutton">
                        <input type="button" id="btn_Reg" onclick="return Register();" style="cursor: pointer;
                            width: 83px; height: 34px; background: url(image/BtnUserRegister.png) 0px 0px no-repeat;" /></div>
                </div>
            </div>
            <div class="cpzx_zc_main1r">
            </div>
        </div>
    </div>
    <input type="hidden" id="hid_MobileVerify" />
    <div id="login" style="position: absolute; z-index: 9001; display: none;">
        <div class="regist_ok_msg" style="margin-top: 10px;">
            <div class="download-btn-default" onmouseover="$(this).addClass('download-btn-mouseover');"
                onmouseout="$(this).removeClass('download-btn-mouseover');" onclick="CloseDiv();">
                立即下载</div>
            <div class="msg-info">
                <div class="msg_title">
                    注册成功！</div>
                <div class="msg_info">
                    <span id="userName">可手机注册，立即使用<br />
                        全功能Level2！</span></div>
                <div class="msg_handlers">
                    <input type="button" id="btn_Login" style="background: url(image/LoginBtnOK2.png) 0px 0px no-repeat;
                        width: 83px; height: 34px; cursor: pointer;" />
                    <input type="button" id="btn_SetAccount" style="background: url(image/buttonws_07.png) 0px 0px no-repeat;
                        width: 93px; height: 34px; cursor: pointer; display: none;" />
                </div>
            </div>
        </div>
        <input type="hidden" id="txt_LoginPW" />
        <input type="hidden" id="txt_LoginName" />
    </div>
    <div id="fullscreem" style="display: none; background-color: Gray; filter: alpha(opacity=50);
        opacity: 0.5; width: 100%; height: auto; position: absolute; top: 0px; left: 0px;
        z-index: 5;">
    </div>
    <script type="text/jscript">

        //更新验证码
        function GetCode() {
            $("#regimgcode").attr("src", "../ePioneer/RegImg.aspx?id=" + Math.random());
        }

        //定位到当前屏幕中间
        function PitchDIV(pop) {
            $("#fullscreem").show();
            if (pop != null && pop != "undefined" && pop != "") {
                var left_w = ($(document).width() - pop.width()) / 2;
                var top_w = $('html').scrollTop() + ($(window).height() - pop.height()) / 2;
                pop.css({ top: top_w, left: left_w });
            }
            $("#fullscreem").css("height", $(document).height());
        }

        //关闭正在加载层
        function CloseDialog() {
            $(document).progressDialog.hideDialog();
        }

        //打开正在加载层
        function OpenDialog() {
            $(document).progressDialog.showDialog("<center>Please wait...</center>");
        }

        //关闭Div
        function CloseDiv() {
            $("#login").hide();
            $("#fullscreem").hide();
        }
        //获取验证码
        function GetMobileVerify() {
            var mobile = $.trim($("#txt_RegMobile").val());
            var testMobile = new RegExp("^0{0,1}(13[0-9]|15[0-9]|180|147|182|18[4-9])[0-9]{8}$");
            if (!testMobile.test(mobile)) {
                $("#regMobileMsg").show();
                return false;
            }
            else {
                ResetRegMsg();
            }
            $.ajax({
                type: "POST",
                url: "../UpdateUserInfo.ashx",
                dataType: "json",
                data: { action: "GetMobileVerify", mobile: mobile },
                success: function (result) {
                    if (result[0] == '0') {
                        $("#hid_MobileVerify").val(result[2]);
                        alert(result[1]);
                    }
                    else if (result[0] == '-2') {
                        $("#regMobileMsg .cpzx_zc_x1").html("该手机号已被注册");
                        $("#regMobileMsg").show();
                        return false;
                    }
                    else {
                        alert(result[1]);
                        return false;
                    }
                }
            });
        }
        //重置提示信息
        function ResetRegMsg() {
            $("#regNameMsg").hide();
            $("#regPwMsg").hide();
            $("#regPwdMsg").hide();
            $("#regMobileMsg").hide();
            $("#regMobileCodeMsg").hide();
            $("#regCheckCodeMsg").hide();
        }

        //注册
        function Register() {
            OpenDialog();
            var userid = $.trim($("#txt_RegName").val()).toLowerCase();
            var password = $.trim($("#txt_RegPW").val());
            var txt_RegPW = $.trim($("#txt_RegPWD").val());
            var mobile = $.trim($("#txt_RegMobile").val());
            var mobileCode = $.trim($("#txt_MobileCode").val());
            var checkcode = $.trim($("#txt_RegCheckCode").val());
            var hid_MobileVerify = $.trim($("#hid_MobileVerify").val());
            if (userid == "") {
                $("#regNameMsg .cpzx_zc_x1").html("昵称不能为空");
                $("#regNameMsg").show();
                CloseDialog();
                return false;
            }
            else {
                var testUserId = new RegExp("^{cps|ems|emoney}*$");
                if (testUserId.test(userid)) {
                    $("#txt_RegName").val("");
                    $("#regNameMsg .cpzx_zc_x1").html("昵称不能以cps/<br />emoney/ems开头");
                    $("#regNameMsg").show();
                    CloseDialog();
                    return false;
                }
                else {
                    testUserId = new RegExp("^[0-9][a-zA-Z0-9]{0,50}$");
                    if (testUserId.test(userid)) {
                        $("#regNameMsg .cpzx_zc_x1").html("昵称不能以数字开头");
                        $("#regNameMsg").show();
                        CloseDialog();
                        return false;
                    }
                    else {
                        testUserId = new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
                        if (testUserId.test(userid)) {
                            $("#txt_RegName").val("");
                            $("#regNameMsg .cpzx_zc_x1").html("昵称不能是邮箱地址");
                            $("#regNameMsg").show();
                            CloseDialog();
                            return false;
                        }
                        else {
                            testUserId = new RegExp("^[a-zA-Z][a-zA-Z0-9]{1,50}$");
                            if (!testUserId.test(userid)) {
                                $("#regNameMsg .cpzx_zc_x1").html("昵称格式不正确");
                                $("#regNameMsg").show();
                                CloseDialog();
                                return false;
                            }
                            else {
                                ResetRegMsg();
                            }
                        }
                    }
                }
            }

            if (password.length < 6) {
                $("#regPwMsg").show();
                CloseDialog();
                return false;
            }
            else {

                if (txt_RegPW != password) {
                    $("#regPwdMsg").show();
                    CloseDialog();
                    return false;
                } else {
                    ResetRegMsg();
                }
            }


            if (mobile != "") {
                var testMobile = new RegExp("^0{0,1}(13[0-9]|15[0-9]|180|147|182|18[4-9])[0-9]{8}$");
                if (!testMobile.test(mobile)) {
                    $("#regMobileMsg .cpzx_zc_x1").html("请输入有效手机<br />号码");
                    $("#regMobileMsg").show();
                    CloseDialog();
                    return false;
                }
                else {
                    $("#regMobileMsg").hide();
                }
                if (mobileCode == "") {
                    $("#regMobileCodeMsg .cpzx_zc_x1").html("验证码不能为空");
                    $("#regMobileCodeMsg").show();
                    CloseDialog();
                    return false;
                }
                else {
                    ResetRegMsg();
                }
            }

            if (checkcode == "") {
                $("#regCheckCodeMsg .cpzx_zc_x1").html("验证码不能为空");
                $("#regCheckCodeMsg").show();
                CloseDialog();
                return false;
            }
            ResetRegMsg();
            $.ajax({
                type: "POST",
                url: "../ePioneer/CheckCode.aspx",
                dataType: "html",
                data: { checkcode: checkcode },
                success: function (data) {
                    if (data == 1) {
                        //调用注册的方法
                        $.ajax({
                            type: "POST",
                            url: "../UpdateUserInfo.ashx",
                            dataType: "json",
                            data: { action: "Register", userid: userid, password: password, mobile: mobile, mobileCode: mobileCode },
                            success: function (result) {
                                CheckResult(result);
                            }
                        });
                        return true;
                    }
                    else {
                        CloseDialog();
                        $("#regCheckCodeMsg .cpzx_zc_x1").html("验证码输入错误");
                        $("#regCheckCodeMsg").show();
                        return false;
                    }
                }
            });
        }

        //
        function CheckResult(result) {
            var userid = $.trim($("#txt_RegName").val()).toLowerCase();
            var password = $.trim($("#txt_RegPW").val());
            CloseDialog();
            if (result[0] == '0') {
                $("#txt_LoginName").val(userid);
                $("#txt_LoginPW").val(password);
                if ($.trim($("#txt_RegMobile").val()) != "") {
                    $("#userName").text("立即体验全功能Level2！");
                }
                //$("#register").hide();
                $("#login").show();
                PitchDIV($("#login"));
            }
            else if (result[0] == '-1') {
                $("#regNameMsg .cpzx_zc_x1").html("该昵称已注册");
                $("#regNameMsg").show();
                return false;
            }
            else if (result[0] == '-2') {
                $("#regMobileMsg .cpzx_zc_x1").html("该手机号已被注册");
                $("#regMobileMsg").show();
                return false;
            }
            else if (result[0] == '-3') {
                $("#regMobileCodeMsg .cpzx_zc_x1").html("手机验证码错误");
                $("#regMobileCodeMsg").show();
                return false;
            }
            else {
                alert(result[1]);
                return false;
            }
        }

        $(document).keydown(function () {
            var e = event.srcElement;
            if (event.keyCode == 13) {
                document.getElementById("btn_Reg").click();
                return false;
            }
        });

        $(document).ready(function () {

            $("#btn_SetAccount").click(function () {
                var userId = $("#txt_LoginName").val();
                var passWord = $("#txt_LoginPW").val();
                $.ajax({
                    type: "POST",
                    url: "../UserInfoCookies.ashx",
                    dataType: "json",
                    data: { userid: userId, password: passWord, loginType: 1 },
                    success: function (result) {
                        window.location.href = "SetAccount.aspx";
                    }
                });
            });

            //点击
            $("#btn_GetCode").mousedown(function () {
                $("#btn_GetCode").css("background", "url(image/GetPwd.PNG) 0px -48px no-repeat");
            });
            $("#btn_GetCode").mouseup(function () {
                $("#btn_GetCode").css("background", "url(image/GetPwd.png) 0px -0px no-repeat");
            });
            //移动
            $("#btn_GetCode").mouseover(function () {
                $("#btn_GetCode").css("background", "url(image/GetPwd.png) 0px -24px no-repeat");
            });
            $("#btn_GetCode").mouseout(function () {
                $("#btn_GetCode").css("background", "url(image/GetPwd.png) 0px -0px no-repeat");
            });

            //点击
            $("#btn_Reg").mousedown(function () {
                $("#btn_Reg").css("background", "url(image/BtnUserRegister.png) 0px -68px no-repeat");
            });
            $("#btn_Reg").mouseup(function () {
                $("#btn_Reg").css("background", "url(image/BtnUserRegister.png) 0px 0px no-repeat");
            });
            //移动
            $("#btn_Reg").mouseover(function () {
                $("#btn_Reg").css("background", "url(image/BtnUserRegister.png) 0px -34px no-repeat");
            });
            $("#btn_Reg").mouseout(function () {
                $("#btn_Reg").css("background", "url(image/BtnUserRegister.png) 0px 0px no-repeat");
            });

            //点击
            $("#btn_SetAccount").mousedown(function () {
                $("#btn_SetAccount").css("background", "url(image/buttonws_07.png 0px -68px no-repeat)");
            });
            $("#btn_SetAccount").mouseup(function () {
                $("#btn_SetAccount").css("background", "url(image/buttonws_07.png 0px 0px no-repeat)");
            });
            //移动
            $("#btn_SetAccount").mouseover(function () {
                $("#btn_SetAccount").css("background", "url(image/buttonws_07.png 0px -34px no-repeat)");
            });
            $("#btn_SetAccount").mouseout(function () {
                $("#btn_SetAccount").css("background", "url(image/buttonws_07.png 0px 0px no-repeat)");
            });

            //点击
            $("#btn_Login").mousedown(function () {
                $("#btn_Login").css("background", "url(image/LoginBtnOK2.png) 0px -68px no-repeat");
            });
            $("#btn_Login").mouseup(function () {
                $("#btn_Login").css("background", "url(image/LoginBtnOK2.png) 0px 0px no-repeat");
            });
            //移动
            $("#btn_Login").mouseover(function () {
                $("#btn_Login").css("background", "url(image/LoginBtnOK2.png) 0px -34px no-repeat");
            });
            $("#btn_Login").mouseout(function () {
                $("#btn_Login").css("background", "url(image/LoginBtnOK2.png) 0px 0px no-repeat");
            });
        });
 
 
    </script>
</body>
</html>
